#@author amith jayasekara 
#simple deployment script for webarchi assingment 
#
#TODO run a bat file for windows enviroment 
# 

# Building war file for the project 
# this will clean target files and install the war file to the maven repository
echo "cleaning project "
mvn clean install -Dmaven.test.skip

echo "attempt to stopping existing catalina instance "
# Stopping existing tomcat instance 
sh $CATALINA_HOME/bin/catalina.sh stop -force

#removing existing war file 
rm -rf $CATALINA_HOME/webapps/webar*

#removing for work folder 
rm -rf $CATALINA_HOME/work/Catalina/localhost/webar*

#copy war file form the ratget file
cp target/*.war $CATALINA_HOME/webapps
pushd .
cd $CATALINA_HOME/bin/
    ./catalina.sh run
pushd
